Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

459
Visualizações
JsPDF Uncaught ReferenceError: jsPDF is not defined"

I am trying to save a div as a PDF using jsPDF. Here is my fiddle: https://jsfiddle.net/waleedbinahmed/bfj6qktv/11/ and here is a fiddle that someone else has uploaded: https://jsfiddle.net/waleedbinahmed/8s4qvu27/

The second fiddle is working fine.

I have tried to mimic the second fiddle i.e. including the same js and Jquery libraries. But on my fiddle, I am getting this error "Uncaught ReferenceError: jsPDF is not defined".

I don't know what I am missing on my fiddle that is causing the issue. Please help me out with what needs to be updated with respect to the second fiddle so that I can save a div a PDF.

JS library: https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.2.61/jspdf.debug.js

Here is my code: HTML:

<div id="content">
  <h3>Hello, this is a H3 tag</h3>

  <p>A paragraph</p>
</div>
<div id="editor"></div>
<button onclick="javascript:createPdf()" id="cmd">generate PDF</button>

Javascript:

function createPdf() {
     var doc = new jsPDF();
    
      source = $('#content')[0];
    
      specialElementHandlers = {
        '#editor': function(element, renderer) {
          return true
        }
      };
    
      doc.fromHTML(
        source,
        15,
        15, {
          'width': 170,
          'elementHandlers': specialElementHandlers
        }
      );
      doc.save('sample-file.pdf')
    }

thanks.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

i did watch to your fiddle (the first one that was not working correctly), and just paste js library from the correct fiddle

and its working. sounds like your imported library doesn't work. and also the working fiddle has a jquery 3.4.1 implemented

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda